﻿using System;
using System.Collections.Generic;
using System.Data.Objects;
using System.Data.Objects.DataClasses;
using System.Data.SqlClient;
using System.Linq;
using System.Linq.Expressions;
using System.Text.RegularExpressions;
using GSLMS.Entity.Enum;
using GSLMS.Entity;
using GSLMS.Entity.DTO;
using GSLMS.Core;
using GSLMS.DAL;

namespace GSLMS.Services
{
    public class BaseService<T> where T : class,new()
    {
        public virtual BaseDAL<T> DAL
        {
            get;
            set;
        }
        /// <summary>
        /// 分页提取数据
        /// </summary>
        /// <param name="searchPara"></param>
        /// <returns></returns>
        public virtual List<T> GetList(T searchPara)
        {
            return DAL.GetList(searchPara)??new List<T>();
        }

        /// <summary>
        /// 提取单条记录信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public virtual T GetByID(long ID)
        {

            return DAL.GetByID(ID)??new T();
        }


        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public virtual bool Add(T model)
        {
            return DAL.Add(model);
        }

        /// <summary>
        /// 编辑
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public virtual bool Update(T model)
        {
            return DAL.Update(model);
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public virtual bool Delete(long ID)
        {
            return DAL.Delete(ID);
        }
    }
}
